package com.artPreter.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;

import com.artPreter.pojo.other.HttpRealData;
import com.artPreter.pojo.vos.page.AlertDevicePageVO;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 温度记录表
 * </p>
 *
 * @author Jarvis_He
 * @since 2024-04-22
 */
@Getter
@Setter
@TableName("jv_alert_memo")
public class AlertMemo implements Serializable {

    private static final long serialVersionUID = 1L;

    //ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    //创建时间")
    @TableField("create_time")
    private long createTime;

    //排序")
    @TableField("sort")
    private Integer sort;

    //备注")
    @TableField("remarks")
    private String remarks;

    //1启用")
    @TableField("status")
    private Integer status;

    //数值")
    @TableField("value")
    private Integer value;

    //是否警报")
    @TableField("is_over")
    private Integer isOver;

    //区域id")
    @TableField("position")
    private String position;

    //楼层id")
    @TableField("floor")
    private String floor;

    //房间id")
    @TableField("room")
    private String room;

    //报警设备uuid")
    @TableField("device_id")
    private String deviceId;

    //地点名称")
    @TableField("posi_name")
    private String posiName;

    //楼层名称")
    @TableField("floor_name")
    private String floorName;

    //房间名称")
    @TableField("room_name")
    private String roomName;

    //警报信息
    @TableField("msg")
    private String msg;

    @TableField(exist = false)
    private String startTime;

    @TableField(exist = false)
    private String endTime;

    public AlertMemo() {
    }

    public AlertMemo(HttpRealData realData, AlertDevicePageVO device) {
        // 备注
        this.remarks = device.getRemarks();
        // 是否警报
        if(realData.getIsalarm()!=null &&realData.getIsalarm().equals("1")){
            this.isOver = 1;
        }else{
            this.isOver = 0;
        }
        // 区域uuid
        this.position = device.getPosition();
        // 区域名称
        this.posiName = device.getPosiName();
        // 楼层uuid
        this.floor = device.getFloor();
        // 楼层名称
        this.floorName = device.getFloorName();
        // 库房uuid
        this.room = device.getRoom();
        // 库房名称
        this.roomName = device.getRoomName();
        // 设备uuid
        this.deviceId = device.getUuid();
        // 警报信息
        this.msg = realData.getChname()+"警报";
        // 发生时间
        Long timeLong = System.currentTimeMillis()/1000;
        this.createTime = timeLong;
    }
}
